package win.bigwhale.sudoku.logic;

import java.awt.Point;

public class SudokuMap {
	private static SudokuMap sudokuMap = new SudokuMap();
	private SudokuNumber[][] numbers = new SudokuNumber[9][9];

	private SudokuMap() {
		initialOccupied();
	}

	private void initialOccupied() {
		for (int i = 0; i < 9; i++) {
			for (int j = 0; j < 9; j++) {
				numbers[i][j] = null;
			}
		}
	}

	public static SudokuMap getSudokuMap() {
		return sudokuMap;
	}

	public boolean isValid(int x, int y) {
		if (numbers[x][y] == null) {
			return true;
		}
		return false;
	}

	public boolean isValid(Point point) {
		if (numbers[point.x][point.y] == null) {
			return true;
		}
		return false;
	}

	public SudokuNumber getSudokuNumber(int x, int y) {
		return numbers[x][y];
	}

	public SudokuNumber getSudokuNumber(Point point) {
		return numbers[point.x][point.y];
	}

	public void setValid(int x, int y, SudokuNumber value) {
		numbers[x][y] = value;
	}

	public void setValid(Point point, SudokuNumber value) {
		numbers[point.x][point.y] = value;
	}

	public boolean isFull() {
		for (int i = 0; i < 9; i++) {
			for (int j = 0; j < 9; j++) {
				if (numbers[i][j] == null) {
					return false;
				}
			}
		}
		return true;
	}
}
